﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using OMS.OMSService;

namespace OMS.Models
{
    public class CreditCardModelView
    {
        public CreditCardModelView() { }

        public CreditCardModelView(OMS.OMSService.CreditCardModel creditCardModel)
        {
            Id = creditCardModel.Id;
            _Type = creditCardModel._Type;
            Number = creditCardModel.Number;
            Cv2 = creditCardModel.Cv2;
            StartDate = creditCardModel.StartDate;
            ExpiryDate = creditCardModel.ExpiryDate;
            IssueNumber = creditCardModel.IssueNumber;
        }

        public CreditCardModel ToCreditCardModel()
        {
            CreditCardModel creditCard = new CreditCardModel
            {
                Id = this.Id,
                _Type = this._Type,
                Number = this.Number,
                Cv2 = this.Cv2,
                StartDate = this.StartDate,
                ExpiryDate = this.ExpiryDate,
                IssueNumber = this.IssueNumber,
            };
            return creditCard;
        }

        #region setters
        public int Id { get; set; }

        [Required]
        [Display(Name = "Credit Card Type")]
        public string _Type { get; set; }

        [Required]
    //    [StringLength(16, ErrorMessage = "The {0} must be {2} characters long.", MinimumLength = 16)]
        [Display(Name = "Credit Card Number")]
        public string Number { get; set; }

        [Required]
       // [StringLength(3, ErrorMessage = "The {0} must be {2} characters long.", MinimumLength = 3)]
        [Display(Name = "CVV2 Code")]
        public int Cv2 { get; set; }

        [Required]
        [DataType(DataType.Date)]
        [Display(Name = "Start Date (Maestro only)")]
        public DateTime StartDate { get; set; }

        [Required]
        [DataType(DataType.Date)]
        [Display(Name = "Expiry Date")]
        public DateTime ExpiryDate { get; set; }

        [StringLength(1, ErrorMessage = "The {0} must be {2} characters long.", MinimumLength = 1)]
        [Display(Name = "Issue Number (Maestro only)")]
        public string IssueNumber { get; set; }

        #endregion
    }
}